<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>公司信息</title>
<link rel="stylesheet" href="libs/layui/css/layui.css" media="all">
</head>
<body>
<form class="layui-form"> <!-- 提示：如果你不想用form，你可以换成div等任何一个普通元素 -->
  <div class="layui-form-item" style="display:none">
    <label class="layui-form-label">id</label>
    <div class="layui-input-block">
      <input type="text" id="id" name="id" placeholder="请输入" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">公司热线</label>
    <div class="layui-input-block">
      <input type="text" id="zuoji" name="zuoji" placeholder="请输入" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">公司电话</label>
    <div class="layui-input-block">
      <input type="text" id="dianhua" name="dianhua" placeholder="请输入" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">公司邮箱</label>
    <div class="layui-input-block">
      <input type="text" id="youxiang" name="youxiang" placeholder="请输入" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">公司地址</label>
    <div class="layui-input-block">
      <input type="text" id="dizhi" name="dizhi" placeholder="请输入" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">公司介绍</label>
    <div class="layui-input-block">
      <textarea name="jieshao" id="jieshao" placeholder="请输入内容" class="layui-textarea"></textarea>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">图片路径</label>
    <div class="layui-input-block">
    	<button type="button" class="layui-btn" id="test1">
 			 <i class="layui-icon">&#xe67c;</i>上传图片
		</button>
		<img id="disImg" width="80" height="80"  alt=""/>
      <input id="imgurl" style="display:none" type="text" name="lunbotu" placeholder="请输入" autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="*">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>
<script src="libs/layui/layui.js" charset="utf-8"></script> 
<script>
layui.use(['form','upload'], function(){
	  var form = layui.form;
	  var $=layui.jquery;
	  var upload = layui.upload;
	  
	  //执行实例
	  var uploadInst = upload.render({
	    elem: '#test1' //绑定元素
	    ,url: 'imgupoad' //上传接口
	    ,done: function(res){
	      //上传完毕回调
	      if(res.code==0){//上传成功
	    	  $("#imgurl").val(res.data);
	      	  $("#disImg").attr("src","img/"+res.data);
	      }else{
	    	  layer.msg("上传失败");
	      }
	      
	    }
	    ,error: function(){
	      //请求异常回调
	    }
	  }); 
  
  form.on('submit(*)', function(data){
	  console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}
	  $.ajax({
		  url:"updateifm",
		  type:"post",
		  data:data.field,
		  success:function(res){
			  if(res=="1"){
				  layer.msg("修改成功");
			  }else{
				  layer.msg("修改失败");
			  }
		  }
	  });
	  
	  return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
	});

});
</script>
</body>
</html>